package LeetCode.month02.day37;

public class No28 {
    public int strStr(String haystack, String needle) {
        if(!haystack.contains(needle)) return -1;
        int left = 0;
        int n = haystack.length();
        int m = needle.length();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(haystack.charAt(i));
            if(i<m-1) continue;
            if(needle.equals(sb.toString())) return left;
            left++;
            sb.deleteCharAt(0);
        }
        return -1;
    }
}
